package com.powernobug.util;

import com.powernobug.bean.vo.BaseRespVo;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @Author: 肖云戈
 * @CreateTime: 2024-08-27
 * @Description:
 */
public class DispatchUtil {
    private DispatchUtil() {}

    public static BaseRespVo taskDispatcher(String operation, HttpServletRequest req, HttpServlet instance) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Method targetMethod = instance.getClass().getDeclaredMethod(operation, HttpServletRequest.class);
        targetMethod.setAccessible(true);
        return (BaseRespVo) targetMethod.invoke(instance, req);
    }
}
